package com.wx.regex;

import java.util.regex.Pattern;

public class RegexUtils {


    public static Boolean mobile(String mobile) {
        String regex = "[\\d]{11}";
        return Pattern.matches(regex, mobile);
    }

    public static Boolean email(String email) {
        String regex = "[a-z\\d]?[\\w\\.]*@\\w*\\.[\\w]*";
        return Pattern.matches(regex, email);
    }

    public static Boolean isIntDouble(String num){
        String regex = "[\\d]+\\.?[\\d]*";
        return Pattern.matches(regex, num);
    }

    //2018-12-6
    public static Boolean time(String date){
        String regex = "[\\d]{4}-[\\d]{1,2}-[\\d]{1,2}";
        return Pattern.matches(regex, date);
    }
    //<a>wahaha</a>
    public static Boolean customeLinkTag(String str){
        String regex = "<a>[\\w]*</a>";
        return Pattern.matches(regex, str);
    }

    public static void main(String[] args) {
//        System.out.println(mobile("13671291886"));
//        System.out.println(email("13671291886"));
//        System.out.println(email("1775924476@qq.com"));
        System.out.println(isIntDouble("123"));
        System.out.println(isIntDouble("123.1"));
        System.out.println(isIntDouble("0.1"));
        System.out.println(isIntDouble(".1"));
        System.out.println(time("2018-1-1"));
        System.out.println(time("2018-01-1"));
        System.out.println(time("2018-01-01"));
        System.out.println(customeLinkTag("<a>wahaha</a>"));
        System.out.println(customeLinkTag("<a>wahaha</a> and <a>haha</a>"));

    }
}
